package mysql

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);unique;"`
	Password string `gorm:"type:char(32);"`
}
type UserRealname struct {
	gorm.Model
	UserId   int64  `gorm:"type:int(10);unique;"`
	Realname string `gorm:"type:varchar(30);"`
	IdCard   string `gorm:"type:char(18);"`
}

func (u *User) FindUser(username string) error {
	return DB.Debug().Where("username=?", username).Find(&u).Error
}
func (ur *UserRealname) Create() error {
	return DB.Create(&ur).Error
}
func (ur *UserRealname) CheckoutRealname(IdCard string, userId int64) error {
	return DB.Debug().Where("id_card=? or user_id=?", IdCard, userId).Find(&ur).Error
}
